package org.example.multiThreading.queue;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class TestConcurrentLinkedQueue {
    public static void main(String[] args) {
        Queue<String> queue = new ConcurrentLinkedQueue<>();
        //像队列添加数据
        queue.add("1");
        queue.add("2");
        queue.offer("3");
        queue.offer("4");
        System.out.println("队列首个元素: "+queue.peek());
        System.out.println("队列总元素: "+queue.size());
        //出队
        int io = queue.size();
        for (int i = 0; i < io; i++) {
            System.out.println("出队元素: "+queue.poll());
        }
        System.out.println("出队完毕，剩余："+queue.size());
    }
}
